package com.wl.api.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.wl.api.common.annotation.RequiresAuthentication;
import com.wl.api.common.utils.JsonObject;
import com.wl.api.common.utils.constant.AppEnum;
import com.wl.api.controller.base.CommonController;
import com.wl.api.service.system.ISecurityCountryService;

@RestController
@RequestMapping("/common")
@RequiresAuthentication(getClientType = AppEnum.anonymity_client)
public class PublishedController extends CommonController {
	@Autowired
	ISecurityCountryService countryService;
	
	/**
	 * 
	   @desc 1: 所有area country 2:只查询关联物流渠道的country
	 * @param type
	 * @return
	 */
	@RequestMapping("/areaCountry")
	public JsonObject getCountrys(Integer type) { 
		JsonObject json = JsonObject.getInstance();
		if(2 == type) {
			json.setData(countryService.getPublishedCountry());
		} else {
			json.setData(countryService.selectList(new EntityWrapper<>()));
		}
		setJsonMessage(json);
		return json;
	}
	
	@RequestMapping("/areaCountry/{countryId}")
	public JsonObject getCountry(@PathVariable("countryId") Integer countryId) { 
		JsonObject json = JsonObject.getInstance();
		json.setData(countryService.selectById(countryId));
		setJsonMessage(json);
		return json;
	}
}
